package com.longtime.authing;

import cn.authing.sdk.java.client.ManagementClient;
import cn.authing.sdk.java.model.ManagementClientOptions;
import com.longtime.authing.properties.AuthingProperties;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.annotation.Resource;

/**
 * @author xhc
 * @version 1
 * @date 2025-05-29 10:57:07
 * @description Authing自动配置类
 */
@Configuration
@EnableConfigurationProperties({AuthingProperties.class})
public class AuthingAutoConfig {

    @Resource
    private AuthingProperties properties;

    @Bean
    public ManagementClient managementClient() {
        ManagementClientOptions options = new ManagementClientOptions();
        options.setAccessKeyId(properties.getAccessKeyId());
        options.setAccessKeySecret(properties.getAccessKeySecret());
        return new ManagementClient(options);
    }
}
